using System.Collections.Generic;
using System.IO;
using System.Linq;
using QFramework;
using UnityEngine;

namespace QGameFramework.Tools
{
    public partial class Tool : IUtility
    {
        public List<string> GetURL(string path, FileType fileType)
        {
            switch (fileType)
            {
                case FileType.Video:
                    return Directory.GetFiles(Application.streamingAssetsPath + path, "*.*",
                            SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".mp4") || s.EndsWith(".avi") || s.EndsWith(".mov") ||
                                    s.EndsWith(".mkv")).ToList();
                    break;
                case FileType.Image:
                    return Directory.GetFiles(Application.streamingAssetsPath + path, "*.*",
                            SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".jpg") || s.EndsWith(".png") || s.EndsWith(".jpeg")).ToList();
                    break;
                case FileType.Txt:
                    return Directory.GetFiles(Application.streamingAssetsPath + path, "*.*",
                            SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".txt") || s.EndsWith(".ini")).ToList();
                    break;
            }

            return null;
        }

        public List<string> Full2GetURL(string path, FileType fileType)
        {
            switch (fileType)
            {
                case FileType.Video:
                    return Directory.GetFiles(path + "/", "*.*", SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".mp4") || s.EndsWith(".avi") || s.EndsWith(".mov") ||
                                    s.EndsWith(".mkv")).ToList();
                    break;
                case FileType.Image:
                    return Directory.GetFiles(path + "/", "*.*", SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".jpg") || s.EndsWith(".png") || s.EndsWith(".jpeg")).ToList();
                    break;
                case FileType.Txt:
                    return Directory.GetFiles(path + "/", "*.*", SearchOption.AllDirectories)
                        .Where(s => s.EndsWith(".txt") || s.EndsWith(".ini")).ToList();
                    break;
            }

            return null;
        }
    }


    public enum FileType
    {
        Image,
        Video,
        Txt,
    }
}